/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __ELLIPSOID_H__
#define __ELLIPSOID_H__

#include "./Cuboid.h"
#include "../Renderer/Renderer.h"
#include "../Renderer/ProjectionPlane.h"


class Ellipsoid: public Object3D {
private:
	Cuboid* mBoundingBox;
	Matrix4D mParametersMatrix;
	cFloat mMFactor;
	cBool mResetAdaptiveStep;
	cBool mBoundingBoxVisible;
	cBool mRayCastingPlaneVisible;
	Renderer mRenderer;
	

	cVoid CalculateMatrix(Matrix4D& matrix, Renderer& renderer);
	cWinColor CalculateColor(cInt x, cInt y, Matrix4D pom3);
	cFloat GetGradX(Matrix4D& matrix, cFloat x, cFloat y, cFloat z);
	cFloat GetGradY(Matrix4D& matrix, cFloat x, cFloat y, cFloat z);
	cFloat GetGradZ(Matrix4D& matrix, cFloat x, cFloat y, cFloat z);
	cInt GetZValue(Matrix4D& matrix, cFloat x, cFloat y, cFloat* z);
public:
    /**************************************************************
    * Constructors                                                *
    ***************************************************************/
    Ellipsoid(cFloat fA, cFloat fB, cFloat fC, Renderer &renderer);
    ~Ellipsoid(); 
        
    /**************************************************************
    * Operators                                                   *
    ***************************************************************/


    /**************************************************************
    * Other helpful functions                                     *
    ***************************************************************/
	virtual cVoid Render(Renderer& renderer, Matrix4D& matrix, ProjectionPlane& plane);
	virtual cVoid Transform(Matrix4D& matrix);
	virtual cVoid Transform(Matrix4D& matrix, cBool bRemember);
	virtual cVoid DisplayInfo(Renderer& renderer);
	cVoid UpdateBoundingBox();
	virtual cChar* GetName();
	cVoid ChangeMFactor(cFloat mFactor);
	cVoid ShowHideBoundingBox();
	cVoid ShowHideRayCastingPlane();
	cVoid ChangeA(cFloat fA);
	cVoid ChangeB(cFloat fB);
	cVoid ChangeC(cFloat fC);
	cVoid StartWorking();
};                                                                 

#endif // __ELLIPSOID_H__